<#include "../../inc/header.ftl" />
<#import "/META-INF/spring.ftl" as spring />
<#import "/META-INF/mspring.ftl" as mspring />
<form id="kuaipanForm" name="kuaipanForm" method="post" action="${base}/admin/api/kuaipan/saveSetting">
	<div id="error" class="message error" style="display:none;"></div>
	<table class="infotable">
		<tr>
			<td colspan="3" class="partition">腾讯微博</td>
		</tr>
		<tr>
			<td class="fieldlabel" style="width:150px;">状态:</td>
			<td>
				<div id="tencent_open" style="display:none;">
					<font style="color:blue;">已开启</font>
				</div>
				<div id="tencent_close" style="display:none;">
					<font style="color:red;">已关闭</font>&nbsp;&nbsp;&nbsp;<a href="javascript:openQQAuth();" style="color:blue;text-decoration: underline;">点击这里开通</a>
				</div>
			</td>
			<td class="fieldnotice" style="width:300px;"></td>
		</tr>
		<tr>
			<td class="fieldlabel" style="width:200px;">openid:</td>
			<td>
				<input type="input" class="textinput" style="width:95%;" id="tencent_openid" readonly="readonly"/>
			</td>
			<td class="fieldnotice" style="width:300px;"></td>
		</tr>
		<tr>
			<td class="fieldlabel" style="width:200px;">openkey:</td>
			<td>
				<input type="input" class="textinput" style="width:95%;" id="tencent_openkey" readonly="readonly"/>
			</td>
			<td class="fieldnotice" style="width:300px;"></td>
		</tr>
		<tr>
			<td class="fieldlabel" style="width:200px;">accessToken:</td>
			<td>
				<input type="input" class="textinput" style="width:95%;" id="tencent_accesstoken" readonly="readonly"/>
			</td>
			<td class="fieldnotice" style="width:300px;"></td>
		</tr>
		<tr>
			<td colspan="3" style="text-align:center;"><input type="submit" class="btn" value=" 提 交 " /></td>
		</tr>
	</table>
</form>
<script type="text/javascript">
	//开通腾讯微博授权
	function openQQAuth(){
		//window.open ('${base}/admin/self/auth/tencent/authorize','newwindow','height=450,width=750,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
		window.open ('${base}/admin/self/auth/tencent/authorize','newwindow','toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
	}
	$(document).ready(function(){
		//斑马线
		var tables=document.getElementsByTagName("table");
		var b=false;
		for (var j = 0; j < tables.length; j++){
			var cells = tables[j].getElementsByTagName("tr");
			//cells[0].className="color3";
			b=false;
			for (var i = 0; i < cells.length; i++){
				if(b){
					cells[i].className="color2";
					b=false;
				}
				else{
					cells[i].className="color3";
					b=true;
				};
			};
		}
		
		mlog.form.validate({
			selector : "#kuaipanForm",
			errorLabelContainer : "#error",
			wrapper: 'li',
			onfocusout : false,
			onkeyup : false,
			onclick : false,
			success : function(){
				mlog.utils.scrollTop();
			}
		});
		
		//刷新腾讯微博信息
		$.get('${base}/admin/self/auth/tencent/info', function(rsp){
			if(rsp.success == true && rsp.data.tencentUserinfo != undefined){
				if(rsp.data.tencentUserinfo.success == true){ //如果状态为开启
					$('#tencent_open').fadeIn();
					$('#tencent_openid').val(rsp.data.tencentUserinfo.openid);
					$('#tencent_openkey').val(rsp.data.tencentUserinfo.openkey);
					$('#tencent_accesstoken').val(rsp.data.tencentUserinfo.accessToken);
				}
				else {
					$('#tencent_close').fadeIn();
				}
			}
			else {
				$('#tencent_close').fadeIn();
			}
		});
	});
</script>
<#include "../../inc/footer.ftl" />